package ihm;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JButton;
import java.awt.Dialog.ModalityType;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

@SuppressWarnings("serial")
public class FenetreAjouterCollaborateur extends JDialog{
	private JTextField txtNomAjout;
	private JTextField txtPrenomAjout;
	private JTextField txtMatricule;

	/**
	 * Create the application.
	 */
	public FenetreAjouterCollaborateur() {
		setModal(true);
		setModalityType(ModalityType.APPLICATION_MODAL);
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		this.setTitle("Ajouter un collaborateur");
		this.setBounds(100, 100, 289, 300);
		this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		
		JLabel lblMatricule = new JLabel("Matricule :");
		
		JLabel lblNom = new JLabel("Nom :");
		
		txtNomAjout = new JTextField();
		txtNomAjout.setColumns(10);
		
		JLabel lblPrnom = new JLabel("Prénom :");
		
		txtPrenomAjout = new JTextField();
		txtPrenomAjout.setColumns(10);
		
		JButton btnValiderAjout = new JButton("Valider");
		
		JButton btnAnnuler = new JButton("Annuler");
		btnAnnuler.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
			}
		});
		
		txtMatricule = new JTextField();
		txtMatricule.setColumns(10);
		GroupLayout groupLayout = new GroupLayout(this.getContentPane());
		groupLayout.setHorizontalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(Alignment.TRAILING, groupLayout.createSequentialGroup()
					.addGap(54)
					.addComponent(btnValiderAjout, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE)
					.addGap(29)
					.addComponent(btnAnnuler, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
					.addGap(31))
				.addGroup(groupLayout.createSequentialGroup()
					.addGap(70)
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addComponent(lblMatricule)
						.addComponent(lblPrnom)
						.addComponent(lblNom))
					.addPreferredGap(ComponentPlacement.UNRELATED)
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(1)
							.addComponent(txtPrenomAjout, GroupLayout.DEFAULT_SIZE, 94, Short.MAX_VALUE)
							.addPreferredGap(ComponentPlacement.RELATED))
						.addComponent(txtNomAjout, GroupLayout.DEFAULT_SIZE, 95, Short.MAX_VALUE)
						.addComponent(txtMatricule, GroupLayout.DEFAULT_SIZE, 95, Short.MAX_VALUE))
					.addGap(48))
		);
		groupLayout.setVerticalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addGap(60)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblMatricule)
						.addComponent(txtMatricule, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(29)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblNom)
						.addComponent(txtNomAjout, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(26)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblPrnom)
						.addComponent(txtPrenomAjout, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(29)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(btnValiderAjout)
						.addComponent(btnAnnuler))
					.addContainerGap(35, Short.MAX_VALUE))
		);
		this.getContentPane().setLayout(groupLayout);
	}
}
